page.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use client";
  2. import { GroupType, PrizeTypes } from "@/api/home";
  3. import { server } from "@/utils/client";
  4. import React from "react";
  5. import HomeTabs from "./_home/HomeTabs";
  6. // const HomeTabs = () => import("./_home/HomeTabs");
  7. const TIME = 0;
  8. const getGames = async () => {
  9. return server
  10. .request<GroupType[]>({
  11. url: "/v1/api/front/game_list",
  12. method: "POST",
  13. // next: { revalidate: TIME },
  14. })
  15. .then((res) => {
  16. if (res.code === 200) return res.data;
  17. return [];
  18. });
  19. };
  20. const getPrizeApi = () => {
  21. return server.request<PrizeTypes[]>({
  22. url: "/v1/api/front/games_notice_win",
  23. method: "post",
  24. });
  25. };
  26. export default function Page(props: any) {
  27. const [group, setGroup] = React.useState<GroupType[]>([]);
  28. React.useEffect(() => {
  29. getData();
  30. }, []);
  31. const getData = async () => {
  32. const groupData = await getGames();
  33. setGroup(groupData);
  34. };
  35. //const group = await getGames();
  36. // const result = await getPrizeApi();
  37. if (!group?.length) return null;
  38. return (
  39. <HomeTabs
  40. tabs={group}
  41. // prize={result?.data || []}
  42. />
  43. );
  44. }